package componentes;

import java.applet.Applet;
import java.awt.*;

/**
 * @author Reynald0
 */
public class CompKey extends Applet {
   private Font f;
   private String letra;
   private boolean presionado;

   public void init()
   {
      f = new Font( "Courier", Font.BOLD, 72 );
      presionado = true;
   }

   public void paint( Graphics g )
   {
      g.setFont( f );

      if ( !presionado )
         g.drawString( letra, 75, 70 );
   }

   public boolean keyDown( Event e, int key )
   {
      showStatus( "keyDown: the " + ( char ) key +
                  " was pressed." );

      letra = String.valueOf( ( char ) key );
      presionado = false;
      repaint();

      return true;   
   }

   public boolean keyUp( Event e, int key )
   {
      showStatus( "keyUp: the " + ( char ) key +
                  " was released." );

      return true;  
   }
}
